package com.dcivision.framework;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DcivisionDataSource implements DataSource {

  private static final Log log = LogFactory.getLog(DcivisionDataSource.class);

  Connection connection;

  public DcivisionDataSource() {

  }

  public DcivisionDataSource(Connection tmp) {
    connection = tmp;
  }

  public Connection getConnection() throws SQLException {

    try {
      connection = DatabaseManager.getCurrentConnection();
    } catch (Exception e) {
      log.error(e, e);
    }
    connection.setAutoCommit(false);
    return connection;
  }

  public Connection getConnection(String username, String password) throws SQLException {

    try {
      connection = DatabaseManager.getCurrentConnection();
      connection.setAutoCommit(false);
    } catch (Exception e) {
      log.error(e, e);
    }
    return connection;
  }

  public PrintWriter getLogWriter() throws SQLException {

    return null;
  }

  public int getLoginTimeout() throws SQLException {

    return 0;
  }

  public void setLogWriter(PrintWriter out) throws SQLException {

  }

  public void setLoginTimeout(int seconds) throws SQLException {

  }

}
